<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.lynn.salary.util.PageTable"%>
<%@page import="com.lynn.salary.util.Operator"%>
<%@page import="com.opensymphony.xwork2.util.ValueStack"%>
<%@page import="com.lynn.salary.util.Page"%>
<%@page import="com.lynn.salary.util.PageColumn"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	ValueStack vs = (ValueStack) request.getAttribute("struts.valueStack");
	boolean showToolBar = false;
	Page pg = (Page) vs.findValue("page");
	List<Map<String, Object>> data = (List<Map<String, Object>>) vs.findValue("data");
	PageTable pt = pg.getPageTable();
	List<PageColumn> columns = pt.getColumns();
	List<Operator> lineOperator = pt.getLineOperator();
%>
<form id="pagerForm" method="post" action="<%=basePath%>common.do?pageName=<s:property value='pageName' />&searchTag=<s:property value='searchTag' />">
	<input type="hidden" name="status" value="<s:property value='status' />" /> 
	<input type="hidden" name="keywords" value="<s:property value='keywords' />" /> 
	<input type="hidden" name="pageNum" value="<s:property value='pageNum' />" />
	<input type="hidden" name="numPerPage" value="<s:property value='numPerPage' />" /> 
	<input type="hidden" name="orderField" value="<s:property value='orderField' />" />
	<input type="hidden" name="pageName" value="<s:property value='pageName' />" />
</form>
<div class="pageContent">
	<% 		if (pg.getOperators() != null) { //是否显示操作栏 		%>
	<div class="panelBar">
		<ul class="toolBar">
			<% 		for (Operator op : pg.getOperators()) {
						if (!op.isShow()) 	continue;
			%>
			<li>
				<a class="<%=op.getName()%>" href="<%=basePath + op.getUrl().trim()%>" title="<%=op.getToolTip() %>" target="<%=op.getTarget() %>" rel="<%=op.getRel()%>" height="<%=op.getHeight()%>" width="<%=op.getWidth()%>" warn="<%=op.getWarn() %>" <%=op.getOther() %>> <span> <%=op.getShowName()%> </span> </a> 
			</li>
			<% 		} 		%>
		</ul>
	</div>
	<% 		} 		%>
	<table class="table" width="100%" layoutH="75">
		<thead>
			<tr>
				<% if(pt.isUseBatch()) {	%>
				<th width="22"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
				<% } %>
				<% 	for (PageColumn pc : columns) { 	%>
				<th width="<%=pc.getWidth()%>"><%=pc.getShowName()%></th>
				<% 	} 	%>
				<% if(lineOperator != null && lineOperator.size() != 0) {	%>
				<th width="70">操作</th>
				<%  } %>
			</tr>
		</thead>
		<tbody>
			<% 		for (Map<String, Object> row : data) { 		%>
			<tr target="<%=pt.getTarget()%>" rel="<%=row.get(""+pt.getIdName())%>">
			<% if(pt.isUseBatch()) {	%>
				<td><input name="ids" value="<%=row.get(pt.getIdName()) %>" type="checkbox"></td>
			<% } 	%>
				<% 		for (PageColumn pc : columns) { 		%>
				<td>
					<%
						String v = "";
								if (pc.getType().toLowerCase().equals("date")) {
									Date d = (Date) row.get(pc.getField());
									if (d != null) {
										SimpleDateFormat f = new SimpleDateFormat(pc
												.getFormat().trim());
										v = f.format(d);
									} else {
										v = " - ";
									}
								} else {
									v = ""+row.get(pc.getField());
								}
								if(v == null || v.equals("null")) v = "-";
					%> 
					<%=v%>
				</td>
				<% 		} 		%>
				<% if(lineOperator != null && lineOperator.size() != 0) {	%>
				<td>
					<% for(Operator op : lineOperator) { 
						String idValue = ""+row.get(pt.getIdName());
						String url = op.getUrl().replace("{"+pt.getTarget()+"}",idValue);
					%>
						<a title="<%=op.getToolTip() %>" target="<%=op.getTarget() %>" height="<%=op.getHeight()%>" width="<%=op.getWidth()%>" warn="<%=op.getWarn() %>" href="<%=url %>" class="<%=op.getName() %>"> <%=op.getShowName() %> </a>
					<% } %>
				</td>
				<% } %>
			</tr>
			<% 		} 		%>
		</tbody>
	</table>
	<div class="panelBar">
	
		<div class="pages">
			<span>显示</span> <select name="numPerPage"
				onchange="navTabPageBreak({numPerPage:this.value})">
				<option value="20" <s:if test="numPerPage=='20'">selected="selected"</s:if>>20</option>
				<option value="50" <s:if test="numPerPage=='50'">selected="selected"</s:if>>50</option>
				<option value="100" <s:if test="numPerPage=='100'">selected="selected"</s:if>>100</option>
				<option value="200" <s:if test="numPerPage=='200'">selected="selected"</s:if>>200</option>
			</select> <span>条，共<s:property value='totalCount' />条</span>
		</div>

		<div class="pagination" targetType="navTab" totalCount="<s:property value='totalCount' />" numPerPage="<s:property value='numPerPage' />" pageNumShown="10" currentPage="<s:property value='currentPage' />"></div>

	</div>
</div>

